﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Cosmetic.Logic;
using Cosmetic.DataEntity;
using System.Collections.Generic;

public partial class HotProduct : System.Web.UI.UserControl
{

    private ProductManager m_ProductManager = new ProductManager();

    private int m_ShowCount = 9;
    public int ShowCount
    {
        get { return m_ShowCount; }
        set { m_ShowCount = value; }
    }

    private string m_imageSrc = "../imagesWeb/Hot01.gif";
    public string ImageSrc
    {
        get { return m_imageSrc; }
        set { m_imageSrc = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindProduct();
        }
    }

    private void BindProduct()
    {
        this.lvProduct.DataSource = this.m_ProductManager.GetFocusProductInfo(ShowCount).ToList();
        this.lvProduct.DataBind();
    }

    protected void lvProduct_ItemDataBound(object sender, ListViewItemEventArgs e)
    {

        int i;
        HtmlImage img = e.Item.FindControl("img") as HtmlImage;

        if (img != null)
        {
            i = Convert.ToInt16(e.Item.ClientID.Substring(e.Item.ClientID.Length - 7, 1)) * 3 + Convert.ToInt16(e.Item.ClientID.Substring(e.Item.ClientID.Length - 2)) + 1;
            if (i < 10)
            {
                img.Src = "../imagesWeb/Hot0" + i.ToString() + ".gif";
            }
            else
            {
                img.Src = "../imagesWeb/Hot" + i.ToString() + ".gif";
            }
        }

    }
}